package com.chengqs.rainbow.im.client.constant;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * <B>主类名称：</B>ClientConstants<BR>
 * <B>概要说明：</B>基于设备名动态生成CLIENT_ID<BR>
 *
 * @author: chengqs
 * @create: 2025-09-14 20:09:39
 **/
public class ClientConstants {
    // 基于设备名动态生成CLIENT_ID
    public final static int CLIENT_ID = generateClientId();

    private static int generateClientId() {
        try {
            String deviceName = InetAddress.getLocalHost().getHostName();
            return deviceName.hashCode() & 0x7fffffff; // 确保非负数
        } catch (UnknownHostException e) {
            return 2; // 默认值保持原来的2
        }
    }
}
